package com.yks.demo.lvcr.democlient.utils;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class TestProxy implements InvocationHandler {
    private static final String markStr = "test";

    private Object target;

    public TestProxy(Object object){
        this.target=object;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

      /*  if(method.getName().startsWith(markStr)){
            System.out.println("do method contains [test]");
        }
*/
        System.out.println("do Transaction 。。");
        return method.invoke(target,args);
    }


    public Object getProxy(){
        return Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),target.getClass().getInterfaces(),this);
    }

}
